home *** CD-ROM | disk | FTP | other *** search
/ Exame Informatica 139 / Exame Informatica 139.iso / Internet / NVU / chrome / toolkit.jar / content / global / xml / XMLPrettyPrint.xsl < prev   
Encoding:
Extensible Markup Language  |  2004-07-13  |  5.6 KB  |  164 lines

  1. <?xml version="1.0"?>
  2. <!-- ***** BEGIN LICENSE BLOCK *****
  3.    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.    -
  5.    - The contents of this file are subject to the Mozilla Public License Version
  6.    - 1.1 (the "License"); you may not use this file except in compliance with
  7.    - the License. You may obtain a copy of the License at
  8.    - http://www.mozilla.org/MPL/
  9.    -
  10.    - Software distributed under the License is distributed on an "AS IS" basis,
  11.    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.    - for the specific language governing rights and limitations under the
  13.    - License.
  14.    -
  15.    - The Original Code is mozilla.org code.
  16.    -
  17.    - The Initial Developer of the Original Code is
  18.    - Netscape Communications Corporation.
  19.    - Portions created by the Initial Developer are Copyright (C) 2002
  20.    - the Initial Developer. All Rights Reserved.
  21.    -
  22.    - Contributor(s):
  23.    -   Jonas Sicking <sicking@bigfoot.com> (Original author)
  24.    -
  25.    - Alternatively, the contents of this file may be used under the terms of
  26.    - either the GNU General Public License Version 2 or later (the "GPL"), or
  27.    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.    - in which case the provisions of the GPL or the LGPL are applicable instead
  29.    - of those above. If you wish to allow use of your version of this file only
  30.    - under the terms of either the GPL or the LGPL, and not to allow others to
  31.    - use your version of this file under the terms of the MPL, indicate your
  32.    - decision by deleting the provisions above and replace them with the notice
  33.    - and other provisions required by the LGPL or the GPL. If you do not delete
  34.    - the provisions above, a recipient may use your version of this file under
  35.    - the terms of any one of the MPL, the GPL or the LGPL.
  36.    -
  37.    - ***** END LICENSE BLOCK ***** -->
  38.  
  39. <!DOCTYPE overlay SYSTEM "chrome://global/locale/xml/prettyprint.dtd">
  40.  
  41. <xsl:stylesheet version="1.0"
  42.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  43.                 xmlns="http://www.w3.org/1999/xhtml">
  44.  
  45.   <xsl:output method="xml"/>
  46.  
  47.   <xsl:template match="/">
  48.     <link href="chrome://global/content/xml/XMLPrettyPrint.css" type="text/css" rel="stylesheet"/>
  49.     <link title="Monospace" href="chrome://global/content/xml/XMLMonoPrint.css" type="text/css" rel="alternate stylesheet"/>
  50.     <div id="header">
  51.       <p>
  52.         &xml.nostylesheet;
  53.       </p>
  54.     </div>
  55.     <xsl:apply-templates/>
  56.   </xsl:template>
  57.  
  58.   <xsl:template match="*">
  59.     <div class="indent">
  60.       <span class="markup"><</span>
  61.       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  62.       <xsl:apply-templates select="@*"/>
  63.       <span class="markup">/></span>
  64.     </div>
  65.   </xsl:template>
  66.  
  67.   <xsl:template match="*[node()]">
  68.     <div class="indent">
  69.       <span class="markup"><</span>
  70.       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  71.       <xsl:apply-templates select="@*"/>
  72.       <span class="markup">></span>
  73.  
  74.       <span class="text"><xsl:value-of select="."/></span>
  75.  
  76.       <span class="markup"></</span>
  77.       <span class="end-tag"><xsl:value-of select="name(.)"/></span>
  78.       <span class="markup">></span>
  79.     </div>
  80.   </xsl:template>
  81.  
  82.   <xsl:template match="*[* or processing-instruction() or comment() or string-length(.) > 50]">
  83.     <table>
  84.       <tr>
  85.         <xsl:call-template name="expander"/>
  86.         <td>
  87.           <span class="markup"><</span>
  88.           <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  89.           <xsl:apply-templates select="@*"/>
  90.           <span class="markup">></span>
  91.  
  92.           <div class="expander-content"><xsl:apply-templates/></div>
  93.  
  94.           <span class="markup"></</span>
  95.           <span class="end-tag"><xsl:value-of select="name(.)"/></span>
  96.           <span class="markup">></span>
  97.         </td>
  98.       </tr>
  99.     </table>
  100.   </xsl:template>
  101.  
  102.   <xsl:template match="@*">
  103.     <xsl:text> </xsl:text>
  104.     <span class="attribute-name"><xsl:value-of select="name(.)"/></span>
  105.     <span class="markup">=</span>
  106.     <span class="attribute-value">"<xsl:value-of select="."/>"</span>
  107.   </xsl:template>
  108.  
  109.   <xsl:template match="text()">
  110.     <xsl:if test="normalize-space(.)">
  111.       <div class="indent text"><xsl:value-of select="."/></div>
  112.     </xsl:if>
  113.   </xsl:template>
  114.  
  115.   <xsl:template match="processing-instruction()">
  116.     <div class="indent pi">
  117.       <xsl:text><?</xsl:text>
  118.       <xsl:value-of select="name(.)"/>
  119.       <xsl:text> </xsl:text>
  120.       <xsl:value-of select="."/>
  121.       <xsl:text>?></xsl:text>
  122.     </div>
  123.   </xsl:template>
  124.  
  125.   <xsl:template match="processing-instruction()[string-length(.) > 50]">
  126.     <table>
  127.       <tr>
  128.         <xsl:call-template name="expander"/>
  129.         <td class="pi">
  130.           <?<xsl:value-of select="name(.)"/>
  131.           <div class="indent expander-content"><xsl:value-of select="."/></div>
  132.           <xsl:text>?></xsl:text>
  133.         </td>
  134.       </tr>
  135.     </table>
  136.   </xsl:template>
  137.  
  138.   <xsl:template match="comment()">
  139.     <div class="comment indent">
  140.       <xsl:text><!--</xsl:text>
  141.       <xsl:value-of select="."/>
  142.       <xsl:text>--></xsl:text>
  143.     </div>
  144.   </xsl:template>
  145.  
  146.   <xsl:template match="comment()[string-length(.) > 50]">
  147.     <table>
  148.       <tr>
  149.         <xsl:call-template name="expander"/>
  150.         <td class="comment">
  151.           <xsl:text><!--</xsl:text>
  152.           <div class="indent expander-content"><xsl:value-of select="."/></div>
  153.           <xsl:text>--></xsl:text>
  154.         </td>
  155.       </tr>
  156.     </table>
  157.   </xsl:template>
  158.   
  159.   <xsl:template name="expander">
  160.     <td class="expander">-<div class="spacer"/></td>
  161.   </xsl:template>
  162.  
  163. </xsl:stylesheet>
  164.